<% layout('/layout/default.html', {title: '流程管理', libs: ['dataGrid','icheck']}){ %>
<div class="main-content">
	<div class="box box-main">
		<div class="card-header">
			<i class="fa fa-sitemap"></i> 流程管理
			<div class="header-tools float-right">
				<a href="#" class="btn btn-default btn-sm" id="btnSearch" title="查询"><i class="fa fa-filter"></i> 查询</a>
			</div>
		</div>
		<div class="container-fluid">
			<form id="searchForm" action="${ctx}/act/process/listData" class="form-inline d-none">
				<div class="form-group">
					<label class="control-label">流程分类：</label>
					<div class="control-inline">
						<#form:select path="category" name="label" data="getDictList:act_category" class="form-control select2bs4" />
					</div>
				</div>
				<div class="form-group">
					<button type="submit" class="btn btn-success btn-sm">查询</button>
					<button id="reset" type="reset" class="btn btn-default btn-sm">重置</button>
				</div>
			</form>
			<table id="dataGrid"></table>
			<div id="dataGridPage"></div>
		</div>
	</div>
</div>
<% } %>
<script>
	$.fn.select2.defaults.set('width', '200px');

	$('#dataGrid').dataGrid({
		searchForm: $("#searchForm"),
		columnModel: [
			{header:'流程名称', name:'name', index:'', width:100, align:"center" },
			{header:'流程分类', name:'categoryName', index:'', width:90, align:"center"
			},
			// {header:'流程ID', name:'id', index:'', width:90, align:"center" },
			// {header:'流程KEY', name:'key', index:'', width:90, align:"center" },
			{header:'流程版本', name:'version', index:'', width:60, align:"center" , formatter:function(val, obj, row, act){
					return "V:" + val;
				}},
			{header:'部署时间', name:'deploymentTime', index:'', width:120, align:"center", formatter:"date", formatoptions:{srcformat: 'Y-m-d H:i:s',newformat: 'Y-m-d H:i:s'} },
			{header:'流程XML', name:'resourceName', index:'', width:100, align:"center" , formatter: function(val, obj, row, act){
					return '<a target="_blank" href="${ctx}/act/process/resource/read?procDefId='+ row.id + '&resType=xml" title="查看流程XML">'+val+'</a>';
				}
			},
			{header:'流程图片', name:'diagramResourceName', index:'', width:100, align:"center" , formatter: function(val, obj, row, act){
					return '<a href="${ctx}/act/process/resource/read?procDefId='+ row.id + '&resType=image" class="btnList" title="流程图查看" data-type="diagram">'+val+'</a>';
				}
			},
			{header:'操作', name:'actions', width:100, sortable:false, title:false, align:"center",formatter: function(val, obj, row, act){
					var actions = [];
				<% if(hasPermi('act:process:edit')){ %>
						if(row.suspensionState == 1) {
							actions.push('<a href="${ctx}/act/process/update/suspend?procDefId='+row.id+'" class="btnList" title="挂起流程" data-confirm="确认要挂起该流程吗？"><i class="fas fa-unlink"></i></a>&nbsp;');
						} else {
							actions.push('<a href="${ctx}/act/process/update/active?procDefId='+row.id+'" class="btnList" title="激活流程" data-confirm="确认要激活该流程吗？"><i class="fas fa-link"></i></a>&nbsp;');
						}

						actions.push('<a href="${ctx}/act/process/delete?deploymentId='+row.deploymentId+'" class="btnList" title="删除" data-confirm="确认要删除该流程吗？"><i class="far fa-trash-alt"></i></a>&nbsp;');

					<% } %>

					return actions.join('');
				}}
		],
		// 加载成功后执行事件
		ajaxSuccess: function(data){

		}
	});


	$('#reset').click(function(){
		$('#category').val(null).trigger("change");
	});

</script>